// Fill out your copyright notice in the Description page of Project Settings.


#include "Test/SharedTest/TestActor.h"
#include "Test/PopupBox/Toast/SToastSlate.h"
#include "Test/SharedTest/Test1.h"

// Sets default values
ATestActor::ATestActor()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;
}

// Called when the game starts or when spawned
void ATestActor::BeginPlay()
{
	Super::BeginPlay();
	Test1* Test = new Test1();
	((Test1*)(0))->TestPring();
	//基类对象指向了派生类的成员.多态案例在这也是一样的
	TSharedPtr<ClassBase> ptrbase = MakeShareable(new ClassTop(10));
	TSharedPtr<ClassTop> ptrcast = StaticCastSharedPtr<ClassTop>(ptrbase);
	if (ptrcast.IsValid())
	{
		ptrcast->MyFunc();
	} else
	{
		UE_LOG(TestLog, Warning, TEXT("Failed To ClassTop::MyFunc"));
	}
}

// Called every frame
void ATestActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
}

void ATestActor::AddCustomSlate()
{
	if (GEngine && GEngine->GameViewport)
	{
		TSharedPtr<SWidget> ToastWidget;
		SAssignNew(ToastWidget, SToastSlate);
		GEngine->GameViewport->AddViewportWidgetContent(ToastWidget.ToSharedRef());
	}
}
